Skip to content

TST: add test for .unique() dtype preserving #29515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 14, 2019

Conversation

ganevgv
Copy link
Contributor

@ganevgv ganevgv commented Nov 9, 2019

@alimcmaster1 alimcmaster1 added the Testing pandas testing functions or related to the test suite label Nov 9, 2019
@@ -506,6 +506,33 @@ def test_is_homogeneous_type(self):
assert Series([1, 2])._is_homogeneous_type
assert Series(pd.Categorical([1, 2]))._is_homogeneous_type

@pytest.mark.parametrize(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should go in pandas/tests/test_algos.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @jreback - moved the test there.

([1, 2, 2], [1.0, 2.0], "float64"),
([1, 2, 2], [1.0, 2.0], "complex64"),
([1, 2, 2], [1.0, 2.0], "complex128"),
([True, True, False], [True, False], "bool"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really try to use the existing fixtures for this, e.g. any_numpy_dtype (and just cast the input in numpy before construction), skipping those which don't make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @jreback - now using np.sctypes to extract all dtypes and skipping [bytes, str, np.void].

@pytest.mark.parametrize(
"data, uniques, dtype_list",
[
([1, 2, 2], [1, 2], np.sctypes["int"]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would rather not use numpy references here and instead use our fixtures or definitions in pandas/conftest.py they are much more comprehensive and include pandas types

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, @jreback - now using any_numpy_dtype to extract the dtypes.

@ganevgv ganevgv force-pushed the tests/unique_preserve_dtype_test branch from 94fa0a9 to 14793af Compare November 13, 2019 20:48
@jreback jreback added this to the 1.0 milestone Nov 14, 2019
@jreback jreback merged commit 8ad5c12 into pandas-dev:master Nov 14, 2019
@jreback
Copy link
Contributor

jreback commented Nov 14, 2019

thanks @ganevgv

Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

COMPAT: .unique() should be type preserving
3 participants